package br.com.gsa.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@NamedQuery(
	    name="findAllUfs",
	    query="SELECT u FROM Uf u "
	)
@Entity
@Table(name="UF", schema="APP")
public class Uf implements Serializable {
	
	private static final long serialVersionUID = 6103607500138373207L;

	@Id	
	@Column(name="CO_UF")
	private Long codUf;
	
	@Column(name="SG_UF")
	private String siglaUf;
	
	@Column(name="CO_REGIAO")
	private String codRegiao;
	
	@Column(name="CO_PAIS")
	private Long codPais;
	
	@Column(name="NO_UF")
	private String nomeUf;
	
	@OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY)
	@JoinColumn(name="CO_UF")
	private List<Endereco> enderecos;
	
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((codUf == null) ? 0 : codUf.hashCode());
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		Uf other = (Uf) obj;
		if (codUf == null) {
			if (other.codUf != null) {
				return false;
			}
		} else if (!codUf.equals(other.codUf)) {
			return false;
		}
		return true;
	}
	

	public Long getCodUf() {
		return codUf;
	}

	public void setCodUf(Long codUf) {
		this.codUf = codUf;
	}

	public String getSiglaUf() {
		return siglaUf;
	}

	public void setSiglaUf(String siglaUf) {
		this.siglaUf = siglaUf;
	}

	public String getCodRegiao() {
		return codRegiao;
	}

	public void setCodRegiao(String codRegiao) {
		this.codRegiao = codRegiao;
	}

	public Long getCodPais() {
		return codPais;
	}

	public void setCodPais(Long codPais) {
		this.codPais = codPais;
	}

	public String getNomeUf() {
		return nomeUf;
	}

	public void setNomeUf(String nomeUf) {
		this.nomeUf = nomeUf;
	}

	public List<Endereco> getEnderecos() {
		return enderecos;
	}

	public void setEnderecos(List<Endereco> enderecos) {
		this.enderecos = enderecos;
	}

	

}
